package com.hrbxlh.virtualization.enums;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * @author zhr 2018/11/15 用户登录登出行为枚举
 */
public enum LoginActionEnum {
    LOGIN ((byte)1, "登录"),
    LOGOUT ((byte)2, "登出");

    private Byte code;
    private String message;

    LoginActionEnum(Byte code, String message) {
        this.code = code;
        this.message = message;
    }

    private static Map<Byte, LoginActionEnum> objMap = Maps.newHashMap();

    static {
        for (LoginActionEnum loginActionEnum : LoginActionEnum.values()) {
            objMap.put(loginActionEnum.code, loginActionEnum);
        }
    }

    public Byte getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static LoginActionEnum findByCode(Byte code){
        return objMap.get(code);
    }
}
